<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>一个案例</title>
  <style>
    .active {
      color: red;
    }
  </style>
</head>

<body>
  <script src="/js/vue.js"></script>
  <div id="app">
    <ul>
      <li :class="{active:currentIndex === index}" v-for="(book,index) in books" @click="btnClick(index)">{{index}}-{{book}}</li>
    </ul>
  </div>

  <script>
    let app = new Vue({
      el: "#app",
      data: {
        books: ["哈利波特", "黑森林", "十宗罪", "钢铁是怎样炼成的"
        ],
        currentIndex:''
      },
      methods:{
        btnClick(i){
          this.currentIndex = i
        }
      }
    })
  </script>
</body>

</html>